import 'package:flutter/material.dart';
import 'package:flutter_base/21_getx/counter2Controller.dart';
import 'package:flutter_base/21_getx/counterController.dart';
import 'package:flutter_base/21_getx/get_thirdPage.dart';
import 'package:get/get.dart';

class GetSecond21 extends StatefulWidget {
  const GetSecond21({super.key});

  @override
  State<GetSecond21> createState() => _GetSecond21State();
}

class _GetSecond21State extends State<GetSecond21> {
  // CounterController counterController = Get.put(CounterController());
  CounterController counterController = Get.find<CounterController>();
  Counter2Controller counter2Controller = Get.find<Counter2Controller>();
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    print('第2222个界面----------------');
    print(Get.arguments);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('这是GetSecond21   22222'),
        ),
        body: Column(
          children: [
            ElevatedButton(
                onPressed: () {
                  /// 这里设置的是命名路由跳转

                  Get.offAll(const GetThird());
                },
                child: const Text('注册2')),
            ElevatedButton(
                onPressed: () {
                  counterController.count.value--;
                },
                child: Text('自减运算')),
            Obx(() => Text('${counterController.count.value}')),
            Obx(() => Text('${counter2Controller.str.value}')),
          ],
        ));
  }
}
